using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace CXDB
{
    /// <summary>
    /// Controller class for CX_Company_PingJia
    /// </summary>
    [System.ComponentModel.DataObject]
    public partial class CxCompanyPingJiumController
    {
        // Preload our schema..
        CxCompanyPingJium thisSchemaLoad = new CxCompanyPingJium();
        private string userName = String.Empty;
        protected string UserName
        {
            get
            {
				if (userName.Length == 0) 
				{
    				if (System.Web.HttpContext.Current != null)
    				{
						userName=System.Web.HttpContext.Current.User.Identity.Name;
					}
					else
					{
						userName=System.Threading.Thread.CurrentPrincipal.Identity.Name;
					}
				}
				return userName;
            }
        }
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public CxCompanyPingJiumCollection FetchAll()
        {
            CxCompanyPingJiumCollection coll = new CxCompanyPingJiumCollection();
            Query qry = new Query(CxCompanyPingJium.Schema);
            coll.LoadAndCloseReader(qry.ExecuteReader());
            return coll;
        }
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public CxCompanyPingJiumCollection FetchByID(object Id)
        {
            CxCompanyPingJiumCollection coll = new CxCompanyPingJiumCollection().Where("ID", Id).Load();
            return coll;
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, false)]
        public CxCompanyPingJiumCollection FetchByQuery(Query qry)
        {
            CxCompanyPingJiumCollection coll = new CxCompanyPingJiumCollection();
            coll.LoadAndCloseReader(qry.ExecuteReader()); 
            return coll;
        }
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public bool Delete(object Id)
        {
            return (CxCompanyPingJium.Delete(Id) == 1);
        }
        [DataObjectMethod(DataObjectMethodType.Delete, false)]
        public bool Destroy(object Id)
        {
            return (CxCompanyPingJium.Destroy(Id) == 1);
        }
        
        
    	
	    /// <summary>
	    /// Inserts a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Insert, true)]
	    public void Insert(string CompanyID,string CompanyName,DateTime? UnFeeTime,int? UnFeeCash,string UnFeeDetail,DateTime? ThiefTime1,DateTime? ThiefTime2,int? ThiefCash,string ThiefDetail,DateTime? UnCoopPeakTime,string UnCoopPeakDetail,DateTime? UnCoopLimitTime,string UnCoopLimitDetail,string UnCoopOthers,int? EnterUserId,int? DeptMasterId,string DeptMasterRemark,int? DeptMasterStatus,DateTime? DeptMasterEnteringTime,int? OtherMasterId,DateTime? OtherMasterTime,int? OtherMasterStatus,string OtherMasterRemark,int? ManagerId,int? ManagerStatus,string ManagerRemark,DateTime? ManagerRemarkTime,DateTime? InTime,int? Status,Guid? Guid)
	    {
		    CxCompanyPingJium item = new CxCompanyPingJium();
		    
            item.CompanyID = CompanyID;
            
            item.CompanyName = CompanyName;
            
            item.UnFeeTime = UnFeeTime;
            
            item.UnFeeCash = UnFeeCash;
            
            item.UnFeeDetail = UnFeeDetail;
            
            item.ThiefTime1 = ThiefTime1;
            
            item.ThiefTime2 = ThiefTime2;
            
            item.ThiefCash = ThiefCash;
            
            item.ThiefDetail = ThiefDetail;
            
            item.UnCoopPeakTime = UnCoopPeakTime;
            
            item.UnCoopPeakDetail = UnCoopPeakDetail;
            
            item.UnCoopLimitTime = UnCoopLimitTime;
            
            item.UnCoopLimitDetail = UnCoopLimitDetail;
            
            item.UnCoopOthers = UnCoopOthers;
            
            item.EnterUserId = EnterUserId;
            
            item.DeptMasterId = DeptMasterId;
            
            item.DeptMasterRemark = DeptMasterRemark;
            
            item.DeptMasterStatus = DeptMasterStatus;
            
            item.DeptMasterEnteringTime = DeptMasterEnteringTime;
            
            item.OtherMasterId = OtherMasterId;
            
            item.OtherMasterTime = OtherMasterTime;
            
            item.OtherMasterStatus = OtherMasterStatus;
            
            item.OtherMasterRemark = OtherMasterRemark;
            
            item.ManagerId = ManagerId;
            
            item.ManagerStatus = ManagerStatus;
            
            item.ManagerRemark = ManagerRemark;
            
            item.ManagerRemarkTime = ManagerRemarkTime;
            
            item.InTime = InTime;
            
            item.Status = Status;
            
            item.Guid = Guid;
            
	    
		    item.Save(UserName);
	    }
    	
	    /// <summary>
	    /// Updates a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
	    public void Update(int Id,string CompanyID,string CompanyName,DateTime? UnFeeTime,int? UnFeeCash,string UnFeeDetail,DateTime? ThiefTime1,DateTime? ThiefTime2,int? ThiefCash,string ThiefDetail,DateTime? UnCoopPeakTime,string UnCoopPeakDetail,DateTime? UnCoopLimitTime,string UnCoopLimitDetail,string UnCoopOthers,int? EnterUserId,int? DeptMasterId,string DeptMasterRemark,int? DeptMasterStatus,DateTime? DeptMasterEnteringTime,int? OtherMasterId,DateTime? OtherMasterTime,int? OtherMasterStatus,string OtherMasterRemark,int? ManagerId,int? ManagerStatus,string ManagerRemark,DateTime? ManagerRemarkTime,DateTime? InTime,int? Status,Guid? Guid)
	    {
		    CxCompanyPingJium item = new CxCompanyPingJium();
	        item.MarkOld();
	        item.IsLoaded = true;
		    
			item.Id = Id;
				
			item.CompanyID = CompanyID;
				
			item.CompanyName = CompanyName;
				
			item.UnFeeTime = UnFeeTime;
				
			item.UnFeeCash = UnFeeCash;
				
			item.UnFeeDetail = UnFeeDetail;
				
			item.ThiefTime1 = ThiefTime1;
				
			item.ThiefTime2 = ThiefTime2;
				
			item.ThiefCash = ThiefCash;
				
			item.ThiefDetail = ThiefDetail;
				
			item.UnCoopPeakTime = UnCoopPeakTime;
				
			item.UnCoopPeakDetail = UnCoopPeakDetail;
				
			item.UnCoopLimitTime = UnCoopLimitTime;
				
			item.UnCoopLimitDetail = UnCoopLimitDetail;
				
			item.UnCoopOthers = UnCoopOthers;
				
			item.EnterUserId = EnterUserId;
				
			item.DeptMasterId = DeptMasterId;
				
			item.DeptMasterRemark = DeptMasterRemark;
				
			item.DeptMasterStatus = DeptMasterStatus;
				
			item.DeptMasterEnteringTime = DeptMasterEnteringTime;
				
			item.OtherMasterId = OtherMasterId;
				
			item.OtherMasterTime = OtherMasterTime;
				
			item.OtherMasterStatus = OtherMasterStatus;
				
			item.OtherMasterRemark = OtherMasterRemark;
				
			item.ManagerId = ManagerId;
				
			item.ManagerStatus = ManagerStatus;
				
			item.ManagerRemark = ManagerRemark;
				
			item.ManagerRemarkTime = ManagerRemarkTime;
				
			item.InTime = InTime;
				
			item.Status = Status;
				
			item.Guid = Guid;
				
	        item.Save(UserName);
	    }
    }
}
